package com.yc.cloud.portal.controller;

import com.yc.cloud.common.basic.api.ResponseResult;
import com.yc.cloud.entity.SysDict;
import com.yc.cloud.portal.service.SysDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jakarta.annotation.Resource;
import lombok.val;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 字典表
 *
 * @author Yancy
 * @date 2024-01-24
 */
@RestController
@RequestMapping("/sys/dict")
@Api(value = "字典表", tags = "字典表接口")
public class SysDictController {

    @Resource
    private SysDictService sysDictService;


//    @GetMapping
//    @ApiOperation(value = "字典表列表", notes = "支持分页查询,字段模糊匹配,排序等")
//    public ResponseResult<CommonPage<SysDict>> list(BaseQueryParam param) {
//        val result = sysDictService.list(param);
//        return ResponseResult.success(CommonPage.restPage(result));
//    }


    @GetMapping
    @ApiOperation(value = "通过字典表字段查询", notes = "通过字典表字段查询")
    public ResponseResult<SysDict> get(@ApiParam @RequestParam("dictText") String dictText) {
        val result = sysDictService.getByDictName(dictText);
        return ResponseResult.success(result);
    }


//    @PostMapping
//    @ApiOperation(value = "添加字典表", notes = "添加")
//    public ResponseResult<SysDict> create(@Validated @RequestBody SysDict param) {
//        val result = sysDictService.create(param);
//        return result != null ? ResponseResult.success(result) : ResponseResult.failed();
//    }
//
//
//    @ApiOperation(value = "删除字典表", notes = "通过ID删除")
//    @DeleteMapping(value = "{id}")
//    public ResponseResult<Boolean> delete(@PathVariable @ApiParam(value = "ID", required = true) Long id) {
//        val result = sysDictService.delete(id);
//        return result ? ResponseResult.success(true) : ResponseResult.failed();
//    }
//
//
//    @ApiOperation(value = "修改字典表", notes = "通过ID修改")
//    @PutMapping(value = "{id}")
//    public ResponseResult<SysDict> update(@PathVariable @ApiParam(value = "ID", required = true) Long id, @Validated @RequestBody SysDict param) {
//        val result = sysDictService.update(id, param);
//        return result != null ? ResponseResult.success(result) : ResponseResult.failed();
//    }
}
